﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChoiceFiles_Bottom.aspx.cs" Inherits="Common_ChoiceFiles_Bottom" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
    <link href="../CSS/css.CSS" type="text/css" rel="stylesheet" />
</head>
<body style =" background-image :url('../images/hit_bg.gif');">
    <form id="form1" runat="server">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td style ="height :90%;">
        <asp:TextBox ID="PersNameInfo" TextMode="multiLine" runat ="server" Rows ="5" Columns ="60"></asp:TextBox>
        <input type="hidden" id="PersIDInfo" runat ="server"  /> 
        <input type="hidden" id="PersCode" runat ="server"  /> 
        </td>
      </tr>
      <tr>
       <td align ="center" >
         <input name="Save"  id="Save" type="button" class="botton02" onclick="tijiao()"  value="确定" runat ="server" />  
         <input name="Close"  id="Close" type="button" class="botton02" onclick="window.close()"  value="取消" runat ="server" />  </td>
    </tr>
    </table> 
    
    <input type="hidden" id="Hcode" runat ="server"  />
<input type="hidden" id="HPageID" runat ="server"  />
<input type="hidden" id="HOrgType" runat ="server"  />
<input type="hidden" id="OrgIDInfo" runat ="server"  />
<input type="hidden" id="OrgNameInfo" runat ="server"  />
<input type="hidden" id="Hidden1" runat ="server"  /> 
<input type="hidden" id="Hidden2" runat ="server"  /> 
<input type="hidden" id="POPIDCol" runat ="server"  /> 
<input type="hidden" id="POPNameCol" runat ="server"  /> 

    </form>
    
    <script language ="javascript" type ="text/javascript" >
    var sData = dialogArguments;
    var sPageID = form1.HPageID.value;
    form1.POPIDCol.value = eval("sData.form1.HChoiceID_"+sPageID+".value");
    form1.POPNameCol.value = eval("sData.form1.ChoiceName_"+sPageID+".value");
    //alert(form1.POPIDCol.value);  
    
    form1.PersNameInfo.value = form1.POPNameCol.value;
    form1.PersIDInfo.value = form1.POPIDCol.value;
    
    function tijiao()
      {
        if((form1.OrgIDInfo.value == "" || form1.OrgIDInfo.value == null) && (form1.PersIDInfo.value == "" || form1.PersIDInfo.value == null))
        {
           var obj = dialogArguments;
           var sChoiceID = form1.HPageID.value ;
           var ChoiceNameInfo = "\"\"";
           var ChoiceIDInfo   = "\"\"";
           obj.sChoiceID = sChoiceID;
           obj.ChoiceNameInfo  = ChoiceNameInfo;
           obj.ChoiceIDInfo    = ChoiceIDInfo;
           window.returnValue  = obj;
           window.close();
        }
        else
        {
        //取单个人perscode,对修改前,没有影响
        // parent.RightFrame.form1
       var eles = parent.RightFrame.form1.getElementsByTagName('input');
       var string;
       for(var i=0;i< eles.length;i++)
       {
            if(eles[i].type=='checkbox' && eles[i].checked)
            {
                string =eles[i].parentElement.innerText;
                var index1 = string.lastIndexOf(')');
                if(index1 ==-1)
                continue;
                    string = string.substring(0,index1);
                    index1 =  string.lastIndexOf('(');
                    string = string.substring(index1 +1 ,string.length);
                    form1.PersCode.value = string;
                break;
            }
       }
       
        //
        
            var obj = dialogArguments;
            var iOrgNum = 0 ;
            var iPersNum = 0 ;
            var OrgNum = form1.OrgIDInfo.value.split(',');   //已选的部门ID的个数
            var PersNum = form1.PersIDInfo.value.split(',');   //已选的人员ID的个数
            if(form1.OrgIDInfo.value != "")
            {
                iOrgNum = OrgNum.length;
            }
            if(form1.PersIDInfo.value !="")
            {
                iPersNum = PersNum.length;
            }      
            
            var sChoiceID = form1.HPageID.value ;
            
            var AllowNum = eval("obj.iChoicePoNumber"+sChoiceID);// obj.iChoicePersNumber;
            if(AllowNum!="0")
            {
                if((iOrgNum*1+iPersNum*1)>AllowNum)
                {
                    alert("对不起,你选择的信息已超过"+AllowNum+"个");
                    return;
                }
            } 
            
            var ChoiceNameInfo = "\"" +  form1.PersNameInfo.value + "\"" ;
            var ChoiceIDInfo = "\"" + form1.PersIDInfo.value + "\"" ;       
            var PersCode =  form1.PersCode.value ;            
            obj.sChoiceID = sChoiceID;
            obj.ChoiceNameInfo = ChoiceNameInfo;
            obj.ChoiceIDInfo = ChoiceIDInfo;
            obj.PersCode= PersCode;
            window.returnValue = obj;
            window.close();
        }
     }     
     </script>
</body>
</html>
